Skip to content

Conversation

leongersen
Copy link

Implements #224

I've borrowed the $treatPhpDocTypesAsCertain logic from UselessCastRule.

I'm ignoring mixed type, as that would be covered by PhpStan itself on level 9.

I kept the scope small: there are many more things that could be asserted about casts, such as:

  • Casting floats to ints, this should probably use round/floor/ceil instead;
  • Objects cannot be cast to int/string/float, but they can be cast to array;
  • Many casts are nonsensical. Yes, you can (float)[2.00,2.00] and get 1.00, but should you want to?

I figured these cases would be better handled in other rule(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants